home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: spc@gate.net (Sean 'Captain Napalm' Conner)
- Newsgroups: comp.std.c,comp.lang.c.moderated
- Subject: Re: printf() format extensions - looking for beta testers...
- Date: 13 Apr 1996 08:58:47 -0500
- Organization: CyberGate, Inc.
- Sender: clc@solutions.solon.com
- Approved: clc@solutions.solon.com
- Message-ID: <4kobun$8i2@solutions.solon.com>
- References: <4kgljv$l2p@solutions.solon.com> <4klicn$ndl@solutions.solon.com> <4kll9l$o5h@solutions.solon.com>
- NNTP-Posting-Host: solutions.solon.com
-
- In article <4kll9l$o5h@solutions.solon.com> seebs@taniemarie.solon.com (Peter Seebach) writes:
- >In article <4klicn$ndl@solutions.solon.com>,
- >Ari Lukumies <aril@cmt.lpr.mail.carel.fi> wrote:
- >>Peter Seebach wrote:
- >> > int bangcvt(va_list *ap, char *s, int len, fmtspec *f) {
- >> > strncpy(s, strerror(errno), len);
- >> > s[len - 1] = '\0';
- >> > return strlen(s);
- >> > }
- >
- >>Given the above, how about calls like (well, not a pretty one, but you get the
- >>idea...):
- >
- >> fprintf(stderr, "%-*.2!", something);
- >
- >This would call
- > bangcvt(&ap, buf, len, { '!', something, 2, FMT_LEFT });
- >and leave the interpretation of the width and precision up to bangcvt.
- >flags are or'ed together.
- >
- >It might not work correctly; I think my sample implementation may have a bug
- >in handling flags. The principle is as given, though.
- >
- But there is a potential problem with doing this. What if you use a
- pre-compiled module that has extended printf(), say, using '%#' (unbeknownst
- to you, the documentation may be a bit lax (happens enough)). What happens
- when you try to extend printf() using '%#'? With possible different
- semantics (different type, say)?
-
- -spc (Or does your printf() report a redefinition error?)
-